{extend name='main'}

{block name="button"}

<!-- {if auth("admin/permission.user/add")}
<button data-modal='{:url("add")}' data-title="添加用户" class='layui-btn layui-btn-sm layui-btn-primary'>添加用户</button>
{/if}

{if auth("admin/permission.user/remove")}
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('admin/permission.user/remove')}" data-confirm="确定要删除这些用户吗？" class='layui-btn layui-btn-sm layui-btn-primary'>删除用户</button>
{/if} -->

{/block}

{block name="content"}
<div class="think-box-shadow">
    {include file='permission/user/index_search'}
    <div class="layui-obj">
        {if auth("admin/permission.user/add")}
        <button data-modal='{:url("add")}' data-title="添加用户" class='layui-btn layui-btn-sm layui-btn-primary'>添加</button>
        {/if}
        
        {if auth("admin/permission.user/remove")}
        <button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('admin/permission.user/remove')}" data-confirm="确定要删除这些用户吗？" class='layui-btn layui-btn-sm layui-btn-primary'>删除</button>
        {/if}
     
    </div>
    <table class="layui-table margin-top-0" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>
            <th class='list-table-sort-td'>
                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
            </th>
            <th class='text-left nowrap'>登录账号</th>
            <th class='text-left nowrap'>用户姓名</th>
            <th class='text-left nowrap'>部门名称</th>
            <th class='text-left nowrap'>职位名称</th>
            <th class='text-left nowrap'>联系手机</th>
            <th class='text-center nowrap'>登录次数</th>
            <th class='text-center nowrap'>使用状态</th>
            <th class='text-left nowrap'>创建时间</th>
            <th class='text-left nowrap'>登录时间</th>
            <th class='text-left nowrap'></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
            <td class='list-table-sort-td'>
                <input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input">
            </td>
            <td class='text-left nowrap'>{$vo.username|default=''}</td>
            <td class='text-left nowrap'>{$vo.nickname|default=''}</td>
            <td class='text-left nowrap'>{$vo.department_cn|default=''}</td>
            <td class='text-left nowrap'>{$vo.authorize_cn|default=''}</td>
            <td class='text-left nowrap'>{$vo.phone|default='-'}</td>
            <td class='text-center nowrap'>{$vo.login_num|default=0}</td>
            <td class='text-center nowrap'>{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{else}<span class="color-green">使用中</span>{/eq}</td>
            <td class='text-left nowrap'>日期：{$vo.create_at|format_datetime|str_replace=' ','<br><span class="color-desc">时间：',###|raw}</span></td>
            <td class='text-left nowrap'>{if $vo.login_num>0}日期：{$vo.create_at|format_datetime|str_replace=' ','<br><span class="color-desc">时间：',###|raw}</span>{else} - {/if}</td>
            <td class='text-left nowrap'>

                {if auth("admin/permission.user/pass")}
                <a class="layui-btn layui-btn-normal layui-btn-sm" data-title="设置密码" data-modal='{:url("pass")}?id={$vo.id}'>密 码</a>
                {/if}

                {if auth("admin/permission.user/edit")}
                <a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
                {/if}

                {if $vo.status eq 1 and auth("admin/permission.user/forbid")}
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('forbid')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('admin/permission.user/forbid')}">禁 用</a>
                {elseif $vo.status eq 0 and auth("admin/permission.user/resume")}
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('resume')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('admin/permission.user/resume')}">启 用</a>
                {/if}

                <!--{if auth("admin/permission.user/remove")}
                <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该用户吗？" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('admin/permission.user/remove')}">删 除</a>
                {/if}-->

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>
<style>
    .layui-obj{
        margin-top: 10px!important;
    }
    .layui-tab{
        margin-top: 10px!important;
    }
	.layui-table td, .layui-table th {
		box-sizing: border-box;
	}
</style>
{/block}
